﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;

/// <summary>
/// Summary description for Mail
/// </summary>
public class Mail
{

    public string Send_Email(string SendTo, string Subject, string Body)
    {
        string status = "";
        try
        {
            System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
            mail.To.Add(SendTo);
            mail.From = new MailAddress("minh.pn26@yahoo.com.vn");
            mail.Subject = "Lấy lại mat khau ";
            mail.Body = Body;
            mail.IsBodyHtml = true;
            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            client.EnableSsl = true; //ssl must be enabled for Gmail
            NetworkCredential credentials = new NetworkCredential("minhpn90@Gmail.com", "prettyboynm");
            client.Credentials = credentials;
            try
            {
                client.Send(mail);
                status = "Email đã được gửi đến: " + SendTo + ".";

            }
            catch (Exception exc)
            {
                status = "ko gui duoc: " + SendTo + ".";

            }
        }

        catch (Exception ex)
        {
            status = "Có lỗi:" + ex.Message;
        }
        return status;
    }
}